﻿// -----------------------------------------------------------------------
// <copyright file="TplExtensions.cs" company="">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace Dhgms.TplHelper.Model.Extensions
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading;
    using System.Threading.Tasks;

    /// <summary>
    /// TODO: Update summary.
    /// </summary>
    public static class TplExtensions
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="instance"></param>
        /// <param name="successTask"></param>
        /// <param name="failureTask"></param>
        public static Task AsContinueWith(this System.Threading.Tasks.Task instance, System.Threading.Tasks.Task successTask, System.Threading.Tasks.Task failureTask)
        {
            var task = new ContinuationActionWithFailureBranching(successTask, failureTask);
            return instance.ContinueWith(task.OnPreviousTaskCompletion);
        }
    }
}
